package threadtest;

import java.util.Timer;
import java.util.TimerTask;

public class TimerTest {
	public static void main(String[] args) {
		final Timer t = new Timer();
		TimerTask task1 = new TimerTask() {

			@Override
			public void run() {
				System.out.println("任务一");
				t.cancel();
			}
		};
		
		TimerTask task2 = new TimerTask() {
			
			@Override
			public void run() {
				System.out.println("任务二");
			}
		};
		
		t.schedule(task1, 10000);
		t.schedule(task2, 5000);
	}
}
